package com.sca;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

@RestController
@RequestMapping(value = "/order")
public class OrderController {

	@Autowired
	private MyFeignClient feignClient;

	
//	@HystrixCommand(fallbackMethod = "orderFallBack")//指定熔断之后的降级方法
	@GetMapping(value = "/buy/{id}")
	public JSONObject findById(@PathVariable Integer id) {
		JSONObject product = feignClient.findById(id);
		return product;
	}
	/**
	 * 单一方式:
	 *  降级方法和需要受到保护的方法的返回值一致 ,方法参数一致
	 */
	public String orderFallBack(Integer id) {
		return "单一触发降级方法";
	}
	
}
